/*
 * Copyright (c) 2009 by ZDO Corporation.
 * Author: A. Onur Cinar
 * 
 * http://code.google.com/p/zdo-struts2
 * http://www.zdo.com
 * 
 * This file is part of ZDO Struts 2 Applications.
 *
 * ZDO-Struts2 is free software: you can redistribute it and/or
 * modify it under the terms of  the GNU General Public License
 * as published by the Free Software Foundation, either version
 *  3 of the License, or any later version.
 *
 * ZDO-Struts2 is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY  or  FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 */

package com.zdo.utils;

/**
 * Pagination utils.
 */
@Deprecated
public class PaginationUtils
{
	/**
	 * Gets the index of first item based on the given 
	 * <code>page</code> number and <code>max</code>
	 * items in a page.
	 * 
	 * @param page page number.
	 * @param max max items.
	 * @return index of first item.
	 */
	public static int getFirst (int page, int max)
	{
		return Math.max((page - 1) * max, 0);
	}
	
	/**
	 * Gets the total pages based on the given item 
	 * <code>count</code> and <code>max</code>
	 * items in a page. 
	 * 
	 * @param paga item count.
	 * @param max max items.
	 * @return total pages.
	 */
	public static int getTotalPages (int count, int max)
	{
		return (int) Math.ceil(count / max);
	}	
}
